package com.lys.config;



import com.lys.job.WeatherDataSycJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 */
@Configuration
public class QuartzConfiguration {
    private final static int TIME_OUT=1800;
    @Bean
    public JobDetail weatherDataSyncJobDetail(){
       return JobBuilder.newJob(WeatherDataSycJob.class)
                .withIdentity("WeatherDataSycJob")
                .storeDurably().build();
    }
    @Bean
    public SimpleTrigger weatherDataSyncTrigger(){
        SimpleScheduleBuilder schedBuilder=SimpleScheduleBuilder
                .simpleSchedule()
                .withIntervalInSeconds(TIME_OUT)
                .repeatForever();
        return TriggerBuilder
                .newTrigger()
                .forJob(weatherDataSyncJobDetail())
                .withIdentity("weatherDataSyncJobDetail")
                .withSchedule(schedBuilder).build();
    }
}
